﻿using System;

namespace DailyFx.Book
{
	/// <summary>
	///		Represents an field of <see cref="IRow"/>. 
	/// </summary>
	public class Field : IEquatable<Field>
	{
		/// <summary>
		///		the name of the field .
		/// </summary>
		private readonly string _label;

		/// <summary>
		///		the type of the field data object .
		/// </summary>
		private readonly System.Type _type;


		/// <summary> 
		///		c'tor .
		/// </summary> 
		public Field ( String label, Type type )
		{
			this._label = label;
			this._type = type;
		}

		/// <summary> 
		///		Gets the name of the field. 
		/// </summary> 
		public String Label
		{
			get { return this._label; }
		}

		/// <summary> 
		///		Gets the type of the field. 
		/// </summary> 
		public Type Type
		{
			get { return this._type; }
		} 
 

		/// <summary> 
		///		Checks if 2 fields got the same name . 
		/// </summary> 
		public Boolean Equals( Field other )
		{
			if ( other == null ) 
			{
				return false;
			}
			return this._label.Equals( other._label ) && this._type.Equals( other._type );
		}

		/// <summary>
		/// 
		/// </summary>
		public override Boolean Equals( Object obj )
		{
			return this.Equals (obj as Field );
		}

		/// <summary> 
		///		Returns the hash code for this field. 
		/// </summary> 
		public override Int32 GetHashCode()
		{
			return this._label.GetHashCode();
		}

		/// <summary> 
		///		Returns a string representation of the field. 
		/// </summary> 
		public override String ToString()
		{
			return "Field: " + this._label;
		} 
 
	}


}
